

    import router from '@/router/'

let roles=[
    
        {
            path: '/Home',
            name: 'Home',
            // component: Home,
            component: () => import('@/components/Home'),
            redirect: {name:"Welcome"},
            children:[
              {
                path:'Welcome',//欢迎页
                name:"Welcome",
                // component:Welcome
                component: () => import('@/components/Welcome')
              },
              {
                path:'Foundation',//基础表格
                name:"Foundation",
                // component:Foundation
                component: () => import('@/components/Foundation')
              },
              {
                path:'Options',//tab选项卡
                name:"Options",
                // component:Options
                component: ()=> import('@/components/Options')
              },
              {
                path:'BasicForm',//基本表单
                // component:BasicForm,
                name:"BasicForm",
                component: () => import('@/components/Formrelated/BasicForm')
              },
                {
                  path:'add',//数据添加页
                  name:"add",
                  // component:add
                  component: () => import('@/page/add')
                },
                {
                  name:"Revise:index",
                  path:'Revise:index',//数据修改页
                  // component:Revise
                  component: () => import('@/page/Revise')
               
                },
              {
                name:"RichTextEditor",
                path:'RichTextEditor',//富文本编辑器
                // component:RichTextEditor
                component: () => import('@/components/Formrelated/Three-levelmenu/RichTextEditor')
              },
              {
                name:"markdown",
                path:'markdown',//markdown编辑器
                // component:markdown
                // component: () => import('@/components/Formrelated/Three-levelmenu/markdown')
                component: () => import('@/page/fuyong')
              },
              {
                name:"Fileupload",
                path:'Fileupload',//文件上传
                // component:Fileupload
                component: ()=> import('@/components/Formrelated/Fileupload')
              },
              {
                name:"Customicon",
                path:'Customicon',//自定义图标
                // component:Customicon
                component: ()=> import('@/components/Customicon')
              },
              {
                name:"Schartchart",
                path:'Schartchart',//schart图表
                // component:Schartchart
                component: () => import('@/components/Schartchart')
              },
              {
                name:"DragTheList",
                path:'DragTheList',//拖拽列表
                // component:DragTheList
                component: ()=> import('@/components/DragTheComponent/DragTheList')
              },
              {
                name:"DragBulletFrame",
                path:'DragBulletFrame',//拖拽弹框
                // component:DragBulletFrame
                component: ()=> import('@/components/DragTheComponent/DragBulletFrame')
              },
              {
                name:"internationalization",
                path:'internationalization',//国际化功能
                // component:internationalization
                component: ()=> import('@/components/internationalization')
              },
              {
                name:"Permission",
                path:'Permission',//权限测试
                // component:Permission
                component: ()=> import('@/components/ErrorHandling/Permission')
              },
              {
                name:"Abnormal",
                path:'Abnormal',//404页面
                // component:Abnormal
                component: ()=> import("@/components/ErrorHandling/Abnormal")
              },
              {
                name:"Support",
                path:'Support',//支持作者
                // component:Support
                component: ()=> import('@/components/Support')
              }
              // {
              //   path: '/Home',
              //   name: 'Home',
              //   // component: Home,
              //   component: () => import('@/components/Home'),
              //   // redirect: '/Welcome',
              //   redirect: '/Welcome',
              // }
            ]
          },
          {
            path:'/',
            name:'login',
            component: () => import('../components/login/login.vue')
          }
    
]



export default (houpath) => {
    //当前用户的路由配置
    let currRoles = [];

    // console.log(currRoles);
    // console.log(roles)
    roles.forEach(element => {
      currRoles.push({...element});
    });
  //循环过滤出当前用户的路由配置
    currRoles[0].children = roles[0].children.filter (route =>{

        return houpath.some(item => item.path==route.path)
      });
      //  console.log("roles后",roles[0].children);

      //  console.log("currRoles",currRoles);

      //把路由配置添加到路由对象里
      router.addRoutes(currRoles);
      //  console.log("router",router);
}